package com.imooc;

import org.springframework.web.bind.annotation.*;

/**
 * Created by Administrator on 2020/2/10.
 */
@RestController
@RequestMapping("/test")
//@CrossOrigin
public class TestController {
    @GetMapping("/get1")
    private ResultBean get1(){
        System.out.println("TestController.get1()");
        return  new ResultBean("get1 ok");
    }

    @PostMapping("/postJson")
    private ResultBean postJson(@RequestBody User user){
        System.out.println("TestController.postJson()");
        return  new ResultBean("postJson" + user.getName()+user.getPhone());
    }

    @GetMapping("/getCookie")
    private ResultBean getCookie(@CookieValue(value = "cookie1") String cookie1){
        System.out.println("TestController.getCookie()");
        return  new ResultBean("getCookie"+cookie1);
    }

    @GetMapping("/getHeader")
    private ResultBean getHeader(@RequestHeader("x-header1") String header1,@RequestHeader("x-header2") String header2){
        System.out.println("TestController.getHeader()");
        return  new ResultBean("getHeader"+header1+header2);
    }
}
